/**
 充值记录
 */

layui.define(['form', 'table', 'admin', 'form'], function (exports) {
    var $ = layui.$, table = layui.table, admin = layui.admin, form=layui.form;
    var tableIn = table.render({
        elem: "#list",
        url: "/shengteng/Users/bankList",
        toolbar: "#toolbar",
        defaultToolbar: [],
        title: "提现记录",
        cols: [[
            {type: 'checkbox', fixed: 'left'},
            {field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true},
            {field: 'username', title: '会员名称', width: 200},
            {field: 'mobile', title: '电话', width: 220},
            {field: 'type', title: '提现方式', width: 100,toolbar: "#type"},
            {fixed: 'right', title: '操作', toolbar: '#action', width: 150}
        ]],
        page: true
    })

    table.on("tool(list)", function (val) {
        var event = val.event;
        var id = val.data.id;
        if (event == "edit") {
            var index = layer.open({
                type: 2,
                content: '/shengteng/Users/bankEdit/id/' + id,
                area: ['300px', '300px'],
                maxmin: true
            });
            layer.full(index);
        }
        if (event == "del") {
            layer.confirm("确定删除？", function () {
                admin.req({
                    url: '/shengteng/Users/bankDel'
                    , type: 'post'
                    , data: {id:id}
                    , done: function (res) {
                        layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                            //刷新父页面
                            location.reload();
                        });
                    }
                });
            })
        }
    })


    var active = {
        reload: function () {
            var key = $('#key').val();
            //执行重载
            table.reload('list', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    key: key
                }
            });
        }
    };

    $('.table-head-btn .layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });

    //对外暴露的接口
    exports('bank', {});
});
